{template 'public/header'}

{template 'public/comhead'}

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcss.css">

<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li class="active"><a href="javascript:void(0);">车辆所在城市</a></li>
    <li><a href="{php echo $this->createWebUrl('car');}"><i class="fa fa-refresh"></i>返回二手车列表</a></li>
</ul>
<div class="main ygmain">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">

            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">添加城市首字母</label>
                    <div class="col-sm-9">
                        <input type="text" name="zimu" class="form-control col-sm-3 " value="{$info['zimu']}" style="width: 390px;" />
                        <!-- <input type="submit" name="submit" value="提交" class="btn " style="color: white;background-color: #444444;margin-left: 50px;;"/> -->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">添加城市名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="name" class="form-control col-sm-3 " value="{$info['name']}" style="width: 390px;" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否热门</label>
                    <div class="col-sm-10">
                        <input type="radio" value="1" name="rec" {if $info['rec']==1 || empty($info['rec'])}checked{/if} >是
                        <input type="radio" value="2" name="rec" {if $info['rec']==2 }checked{/if} >否
                    </div>
                </div>
                        <input type="submit" name="submit" value="提交" class="btn " style="color: white;background-color: #444444;margin-left: 50px;;"/>
            </div>


            <input type="hidden" name="token" value="{$_W['token']}" />
            <input type="hidden" name="id" value="{$info['id']}" />
        </div>
    </form>
    <div class="panel panel-default ygdefault">
        <div class="panel-heading wyheader">

            分类列表

        </div>
    </div>
    <div class="panel-body" style="padding: 0px 15px;">
        <div class="row" id="accordion">

            <table class="yg5_tabel col-md-12">

                <tr class="yg5_tr1" style="border-bottom: 1px solid #efefef;font-weight: bold;text-align: center;">
                    <td  style="text-align: center;">编号</td>
                    <td  style="text-align: center;">首字母</td>
                    <td  style="text-align: center;">城市名称</td>
                    <td  style="text-align: center;">是否热门</td>
                    <td>操作</td>
                </tr>

                {loop $info $key $item}
                <tbody>
                <tr class="yg5_tr2" style="border-bottom: 1px solid #efefef;font-weight: bold;text-align: center;">

                    <td>{$item['id']}</td>
                    <td>{$item['zimu']}</td>
                    <td>{$item['name']}</td>
                    <td>{if $item['rec']==1}是{else}否{/if}</td>
                    <td>
                        {if $item['rec']==1}
                            <a href="{php echo $this->createWebUrl('carcity',array('op'=>'rec1','id'=>$item['id']));}"><button class="btn storeblue btn-xs">取消推荐</button></a>
                            {/if}
                            {if $item['rec']==2}
                            <a href="{php echo $this->createWebUrl('carcity',array('op'=>'rec2','id'=>$item['id']));}"><button class="btn storered btn-xs">推荐</button></a>
                            {/if}
                        <a class="storespan btn btn-xs" onclick="del({$item['id']},{$item['num']})">
                            <span class="fa fa-trash-o"></span>
                            <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                        </a>
                    </td>
                </tr>
                </tbody>
                {/loop}
                {if empty($item)}
                <tr class="yg5_tr2">
                    <td colspan="8">
                       暂无分类
                    </td>
                </tr>
                {/if}
            </table>
        </div>
    </div>

</div>
<script type="text/javascript">
    $(function(){
        $("#frame-8").show();
        $("#yframe-8").addClass("wyactive");
    })
    function del(id,num) {
        if(num>0){
            alert('当前城市下有'+num+'辆车，无法删除，请先修改车辆所属城市')
        }else{
            var ret = confirm("您确定删除吗？")
            if (ret==true){
                $.ajax({
                    type:"POST",
                    url:"{php echo $this->createWebUrl('carcity',array('op'=>delete))}",
                    dataType:"JSON",
                    data:{id:id},
                    success:function(res){
                        console.log(res);
                        location.reload();

                    }
                })
            }
        }

    }
</script>